#ifndef VOXEL_PREPROCESSOR_H_
#define VOXEL_PREPROCESSOR_H_

#include "common/data_type.h"

class VoxelProcessor {
 public:
  struct VoxelPreProcessParameters {
    std::vector<float> net_range;
    std::vector<float> voxel_size;
    std::vector<int32_t> mp;
    int32_t max_points_per_voxel;
  };

 public:
  VoxelProcessor() noexcept;
  ~VoxelProcessor();
  VoxelProcessor(VoxelProcessor const&) = delete;
  VoxelProcessor& operator=(VoxelProcessor const&) = delete;
  VoxelProcessor(VoxelProcessor&&) = delete;
  VoxelProcessor& operator=(VoxelProcessor&&) = delete;

  /// @brief do lidar data voxel
  /// @param lidar_data source lidar data
  /// @param parameters parameters
  /// @param voxel_data output voxel data
  /// @param err error message
  /// @return if no error return true, otherwise false
  bool operator()(FixedArray<LidarData, kMaxLidarNum> const& lidar_data,
                  VoxelPreProcessParameters const& parameters,
                  std::vector<float>& voxel_data, std::string& err) noexcept;

 private:
  /// @brief random array
  std::shared_ptr<std::vector<uint32_t>> random_array_ptr_;
  /// @brief  init call once flag
  std::once_flag init_flag_;
  /// @brief number of per voxel
  std::vector<std::vector<std::int16_t>> num_points_per_voxel_;
};

#endif  // !VOXEL_PREPROCESSOR_H_
